package main;

import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;

import javax.imageio.ImageIO;
import javax.swing.*;

//import jobs.Reaper;
import spells.Fireball;
import spells.Heal;
import spells.Ignite;
import spells.IgniteMagic;
import spells.PainSpike;
import spells.Replenish;
import creatures.Wolf;

public class IntroStart extends JFrame implements ActionListener {
	Grid currentGrid;
	TestingPanel imagePanel;
	TestingPanel buttonPanel;
	JFrame chooser;
	
	static Player you;
	static ArrayList<Creature> enemies;
	static String tile;
	Object object;
	int i;
	Enemy enemy;
	
	static IntroChooserPanel choice;
	static IntroStart parent;
	
	JButton newGame = new JButton("New Game");
	JButton loadGame = new JButton("Load Game");
	JButton options = new JButton("Options");
	JButton exitGame = new JButton("Exit");
	public IntroStart () {
		//Initialize
		parent=this;
		enemies=new ArrayList<Creature>();
		enemies.add(new Wolf(5,3,"Wolf 1"));
		enemies.get(0).x=5;
		enemies.get(0).y=3;
		
		enemies.add(new Wolf(2,8,"Wolf 2"));
		enemies.get(1).x=2;
		enemies.get(1).y=8;
		
		enemies.add(new Wolf(6,9,"Wolf 3"));
		enemies.get(2).x=6;
		enemies.get(2).y=9;
		
		tile="tiles/dirt.jpg"/*"grass.gif"*/;
		//End of Initialize
		
		Dimension d = new Dimension (824,646);
		this.setSize(d);
		getContentPane().setLayout(new BoxLayout(getContentPane(), BoxLayout.PAGE_AXIS));
		
		imagePanel = new TestingPanel();
		buttonPanel = new TestingPanel();
		
		File background = new File("HeroesQuestBanner.jpg");
		BufferedImage background1 = null;
		try {
			background1 = ImageIO.read(background);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		ImageIcon background2 = new ImageIcon(background1);
		JLabel background3 = new JLabel();
		background3.setIcon(background2);
		imagePanel.add(background3);
		
		newGame.addActionListener(this);
		loadGame.addActionListener(this);
		options.addActionListener(this);
		exitGame.addActionListener(this);
		
		add(imagePanel);
		
		buttonPanel.add(newGame);
		//buttonPanel.add(loadGame);
		//buttonPanel.add(options);
		buttonPanel.add(exitGame);
		
		add(buttonPanel);
		
		this.setVisible(true);
		this.setResizable(false);
		this.setDefaultCloseOperation(EXIT_ON_CLOSE);
	}

	public static void launch() {
		you=new Player(1,2,choice.getName(),choice.getJob(),1);
		IntroWindow intro = new IntroWindow(parent);
		intro.setVisible(true);
		//BattleGrid test=new BattleGrid(you,enemies,tile,null, 3, (Enemy)enemies.get(0),1);
		//BattleGridTest test=new BattleGridTest(you, new GameGrids(you), 1, parent);
	}
	
	public void actionPerformed(ActionEvent e) {
		if (e.getSource() == newGame){
			JOptionPane.showMessageDialog(null,"GO TO http://sites.google.com/site/heroesquestproject for our online readme before you play (click on Manual/Readme on the sidebar)!!");
			choice = new IntroChooserPanel();
			this.setVisible(false);
		}
		else if (e.getSource() == loadGame) {
			
			this.setVisible(false);
		}
		else if (e.getSource() == options) {
			
			this.setVisible(false);
		}
		else if (e.getSource() == exitGame) {
			this.setVisible(false);
			System.exit(0);
		}
	}
	
	public static void main(String[] args) throws IOException {
		IntroStart t = new IntroStart();
		t.setVisible(true);
	}
	
	public class TestingPanel extends JPanel  {
		public TestingPanel(){
		
		}
	}
}